package javaTec.volatileLearn;

/**
 * Created by yangshunxing on 2017/9/8.
 */
public class VolatileTest {

    public volatile int inc = 0;

    public void increase(){
        inc++;
    }

    public static void main(String[] args) {
        /*final VolatileTest test = new VolatileTest();
        for (int i=0; i<10; i++){
            new Thread(){
                @Override
                public void run() {
                    for (int j=0; j<1000; j++)
                        test.increase();
                }
            }.start();
        }
        while(Thread.activeCount()>1)
            Thread.yield();
        System.out.println(test.inc);*/
//        String str1 = new StringBuilder("计算机").append("技术").toString();
//        System.out.println(str1.intern() == str1);

        String str2 = new StringBuilder("ja").append("va").toString();
        System.out.println(str2.intern() == str2);

        System.out.println(Runtime.getRuntime().maxMemory());
        System.out.println(Runtime.getRuntime().freeMemory());
        System.out.println(Runtime.getRuntime().totalMemory());


    }
}
